clear
set more off

/* PREP
import delim using ".\input\Lilley_et_al_data\1918_npi_effects\data\input\city_employment_manu.csv", clear
tempfile manu
save "`manu'", replace

import delim using ".\input\Lilley_et_al_data\1918_npi_effects\data\input\city_output_manu.csv", clear
merge 1:1 ïcity state using "`manu'", nogen

cap cd "C:\Users\gaetanir.MGT-DF-CG48773\Dropbox\Pandemic_Innovation_Data\input\Lilley_et_al_data"

import delimited using 1918_npi_effects\data\input\city_employment_manu.csv, clear
save temp.dta, replace

import delimited using 1918_npi_effects\data\input\city_output_manu.csv, clear
merge 1:1 ïcity state using temp.dta, nogen

export delim using ".\input\Lilley_et_al_data\merged_lilleyetal.csv", replace
*/

* At this point, manually assign gen_id to each city, save it into merged_lilleyetal_filled.csv (it is easier to do it manually)
* Rename city and state variables as city_l and state_l
* Create a column gen_id, a column region, and a column days_npis
* Eliminate cities without gen_id
* Charleston is the only city among the 50 that is not in the Lilley et al. dataset

* Analyze data within our specification:

import delim using ".\input\Lilley_et_al_data\merged_lilleyetal_filled.csv", clear

reshape long citymanuoutput citymanuemp, i(city_l state_l) j(year)

drop if gen_id == .
gen long_npi = days_npi >= 90

gen log_manuoutput = ln(citymanuoutput)
gen log_manuemp = ln(citymanuemp)

gen post_pandemic = year >= 1919
 
reghdfe log_manuoutput long_npi##year, absorb(gen_id region##year) cluster(gen_id)
reghdfe log_manuemp long_npi##year, absorb(gen_id region##year) cluster(gen_id)

reghdfe log_manuoutput long_npi##post_pandemic, absorb(gen_id region##year) cluster(gen_id)
reghdfe log_manuemp long_npi##post_pandemic, absorb(gen_id region##year) cluster(gen_id)



